/**
* Created by wl
* 项目管理>持有中-详情页-项目详情-对赌回购编辑信息
*/
<template>
    <div  :class="{'ca-box': $route.name.includes('add'), 'ca-m-t-28':  $route.name.includes('add'), 'ca-p-20': $route.name.includes('add')}">
        <div class="ca-title">
            <h3>对赌回购</h3>
            <div class="el-right" v-show="showBtn">
                <el-button type="primary" @click="save" size="small">保存</el-button>
                <el-button @click="close" size="small">取消</el-button>
            </div>
        </div>
        <table class="ca-table ca-m-t-15">
            <tr>
                <th class="el-wid-15">触发时间</th>
                <th class="el-wid-70">触发内容</th>
                <th class="el-wid-15">处置方式</th>
            </tr>
            <tr v-for="(item, index) in gambling" :key="index">
                <td>
                    <el-date-picker
                    type="date"
                    placeholder="选择日期"
                    class="el-wid-90"
                    v-model="item.triggerTime">
                    </el-date-picker>
                </td>
                <td><el-input placeholder="请输入内容" v-model="item.triggerNote" :maxlength="300"></el-input></td>
                <td>
                    <el-select v-model="item.disposalMethods" placeholder="请选择">
                        <el-option
                        v-for="item in dropDown.disposalMethods"
                        :key="item.id"
                        :label="item.name"
                        :value="Number(item.id)">
                        </el-option>
                    </el-select>
                </td>
            </tr>
        </table>
        <table class="ca-table ca-m-t-15">
            <tr>
                <th class="el-wid-15">触发时间</th>
                <th class="el-wid-70">触发内容</th>
                <th class="el-wid-15">处置方式</th>
            </tr>
            <tr v-for="(item, index) in buyBack" :key="index">
                <td>
                    <el-date-picker
                    type="date"
                    placeholder="选择日期"
                    class="el-wid-90"
                    v-model="item.triggerTime">
                    </el-date-picker>
                </td>
                <td><el-input placeholder="请输入内容" v-model="item.triggerNote" :maxlength="300"></el-input></td>
                <td>
                    <el-select v-model="item.disposalMethods" placeholder="请选择">
                        <el-option
                        v-for="item in dropDown.disposalMethods"
                        :key="item.id"
                        :label="item.name"
                        :value="Number(item.id)">
                        </el-option>
                    </el-select>
                </td>
            </tr>
        </table>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    export default {
        data() {
            return {
                itemHoldTextEntity: [], //非对赌部分
                dropDown: {
                    disposalMethods: this.$store.state.user.dictionaryMap.disposalMethods, // 行业
                },
                info: {
                    disposalMethods: null, //处置方式
                    id: null, //id
                    isTrigger: 0, //是否触发 1:是 0:否
                    itemId: null,  //项目ID
                    protocolNote: '', //协议内容
                    protocolTime: '', //协议时间
                    protocolType: 1, //协议类型 1:对赌协议 2:回购协议
                    triggerNote: '', //触发内容
                    triggerTime: new Date() //触发时间
                },
            }
        },
        watch: {
        },
        props: {
            showBtn: {
                type: Boolean,
                default: function () {
                    return false;
                }
            },
            gambling: {
                type: Array,
                default: function () {
                    return [];
                }
            },
            buyBack: {
                type: Array,
                default: function () {
                    return [];
                }
            },
        },
        mounted() {
        },
        methods: {
            close() {
                this.$emit('close')
            },
            save() {
                let query = {
                    itemHoldProtocolEntitys: [...this.gambling, ...this.buyBack],
                    itemId: this.$route.params.itemId,
                    itemHoldTextEntity: this.itemHoldTextEntity,
                }
                apiHttp(api.EDIT_PROTOCOL, query).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.$message({
                            message: '修改成功！',
                            type: 'success',
                            center: true
                        });
                        this.$emit('save')
                    }
                })
            },
        },
        components: {
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-right {
    float: right;
}
.keyProtocol {
    border: 1px solid #ccc;
}
.ca-inner {
    display:table-cell;
    vertical-align:middle;
    background:#999999
}
.icon i {
    font-size: 20px;
    padding: 15px;
}
.el-wid-90 {
    width: 90%;
}
.el-wid-15 {
    width: 15%;
}
.el-wid-70 {
    width: 70%;
}
</style>